<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- vue特点：数据一旦改变，界面就跟着变 -->
        <!-- 当点击按钮时，把msg变成'鸡杀马'的字符串 -->
        <!-- <button v-on:click="msg = '鸡杀吗'">修改msg</button>
        <button v-on:click="fn1">修改msg和age-调用函数</button>
        <button v-on:click="fn2('战战战杀杀杀')">修改msg调用函数并传参</button> -->


        <!-- 简写形式 -->
        <!-- 把v-on：全部替换成@ -->
        <!-- @事件名 -->
        <button @click="msg = '鸡杀吗'">修改msg</button>
        <button @click="fn1">修改msg和age-调用函数</button>
        <button @click="fn2('战战战杀杀杀')">修改msg调用函数并传参</button>
        <p>{{msg}}</p>
        <p>{{age}}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    msg: '马杀鸡',
                    age: 16
                }
            },
            methods: {
                fn1() {
                    //在JS部分访问vue里的数据，前面要加this
                    this.msg = '我淦啊'
                    this.age += 10
                },
                fn2(m) {
                    this.msg = m
                }
            }
        })
    </script>
</body>

</html>